package com.gimi.cloud.bbp.client.controller.moreInfo;

import com.gimi.cloud.bbp.client.service.moreInfo.GongjijingService;
import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.JsonUtil;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.common.utils.reqhead.Util;
import com.gimi.cloud.bbp.dto.app.moreInfo.GongjijingDTO;
import com.gimi.cloud.bbp.entity.app.moreInfo.FengchaoGongjijinRegionEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 蜂巢公积金
 * @auther loongs
 * @date 2018/1/11  11:05
 */
@RestController
@RequestMapping("/moreInfo")
public class GongjijingController {
    private static Logger logger = LoggerFactory.getLogger(GongjijingController.class);
    private GongjijingService gongjijingService;
    @Autowired
    public GongjijingController(GongjijingService gongjijingService) {
        this.gongjijingService = gongjijingService;
    }

    @RequestMapping(value = "/getProvidentFundInfoSupportedCityList")
    public void getProvidentFundInfoSupportedCityList(@RequestBody GongjijingDTO gongjijingDTO, HttpServletResponse response) throws Exception {
        logger.info("获取公积金城市登录列表入参："+gongjijingDTO);
        Response resp = new Response();
        Map<String, Object> data = new HashMap<>();
        List<FengchaoGongjijinRegionEntity> fengchaoGongjijinRegionEntityList= gongjijingService.getProvidentFundInfoSupportedCityList(gongjijingDTO);
        data.put("cityList", fengchaoGongjijinRegionEntityList);
        resp.setRes_data(data);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
    }
    @RequestMapping(value = "/getProvidentFundInfoCityLoginParameter")
    public void getProvidentFundInfoCityLoginParameter(@RequestBody GongjijingDTO gongjijingDTO, HttpServletResponse response) throws Exception {
        logger.info("获取公积金地区登录参数入参："+gongjijingDTO);
        Response resp = new Response();
        Map<String, Object> data = new HashMap<>();
        FengchaoGongjijinRegionEntity fengchaoGongjijinRegionEntity = gongjijingService.getProvidentFundInfoCityLoginParameter(gongjijingDTO);
        data.put("cityLoginParameter", fengchaoGongjijinRegionEntity);
        resp.setRes_data(data);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
    }
    @RequestMapping(value = "/getProvidentFundInfoImage")
    public void getProvidentFundInfoImage(@RequestBody GongjijingDTO gongjijingDTO, HttpServletResponse response) throws Exception {
        logger.info("获取公积金验证码图片入参："+gongjijingDTO);
        Response resp =gongjijingService.getProvidentFundInfoImage(gongjijingDTO);
        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
    }
    @RequestMapping(value = "/getProvidentFundInfo")
    public void getProvidentFundInfo(@RequestBody GongjijingDTO gongjijingDTO, HttpServletResponse response) throws Exception {
        logger.info("登录并且获取公积金信息入参："+gongjijingDTO);
        Response resp = gongjijingService.getProvidentFundInfo(gongjijingDTO);
        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
    }

}
